# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper

  def user_bar
    content_tag(:div, [
      content_tag(:p, t(:welcome, :user => current_user.get_name, :expected => current_user.expected_hours, :worked => current_user.worked_hours)),
      content_tag(:ul, [
        (content_tag(:li, link_to(t(:admin), '/admin', :id => "admin-link")) if current_user.is_administrator?),
        content_tag(:li, link_to(t(:logout), '/logout', :id => "logout-link"))
      ])
    ], :id => "user-bar")
  end

  def default_javascripts
    scripts = []
    %w(prototype effects controls dragdrop).each do |j|
      scripts << content_tag(:script, nil, :type => 'text/javascript', :src => '/javascripts/' + j + '.js')
    end
    scripts.join "\n"
  end

end
